function x_cup = stateTransition(x_cu,model)

if model.pruningOn == 1   
    % note that x_cu and xAll_cup are in dev from steady state.
    if model.appOrder == 1
        xf_cu      = x_cu(1:model.nx,1);
        xf_cup     = model.h0 + model.hx*xf_cu;
        xAll_cup   = xf_cup;
    elseif model.appOrder == 2
        xf_cu                 = x_cu(1:model.nx,1);
        xs_cu                 = zeros(model.nx,1);
        xs_cu(1:model.nx1,1)  = x_cu(model.nx+1:model.nx+model.nx1,1);
        AA_cu                 = kron3(xf_cu,xf_cu);
        xf_cup                = model.h0 + model.hx*xf_cu;
        xs_2nx1_cup           = model.hx(1:model.nx1,:)*xs_cu + model.Hxx(1:model.nx1,:)*AA_cu;
        xAll_cup              = [xf_cup;xs_2nx1_cup];
    elseif model.appOrder == 3
        xf_cu                 = x_cu(1:model.nx,1);
        xs_cu                 = zeros(model.nx,1);
        xs_cu(1:model.nx1,1)  = x_cu(model.nx+1:model.nx+model.nx1,1);
        xrd_cu                = zeros(model.nx,1);
        xrd_cu(1:model.nx1,1) = x_cu(model.nx+model.nx1+1:model.nx+2*model.nx1,1);
        AA_cu                 = kron3(xf_cu,xf_cu);
        BB_cu                 = kron3(xf_cu,xs_cu);
        xf_cup                = model.h0 + model.hx*xf_cu;
        xs_2nx1_cup           = model.hx(1:model.nx1,:)*xs_cu  + model.Hxx(1:model.nx1,:)*AA_cu;
        xrd_2nx1_cup          = model.hx(1:model.nx1,:)*xrd_cu + 2*model.Hxx(1:model.nx1,:)*BB_cu ...
            +  model.Hxxx(1:model.nx1,:)*kron3(xf_cu,AA_cu);
        xAll_cup              = [xf_cup;xs_2nx1_cup;xrd_2nx1_cup];
    end
    x_cup = xAll_cup;
else
    x_cup = zeros(model.nx,1);
    if model.mx > 0
        % update endogenous states (not lagged controls) - in dev from steady state
        x_cup(1:model.mx,1) = updateEndoStates(model,x_cu);
    end
    myx = model.myx;
    if myx > 0
        % lagged controls
        if model.appOrder == 1
            y1_cu = model.g0(1:myx,1) + model.gx(1:myx,:)*x_cu;
        elseif model.appOrder == 2
            y1_cu = model.g0(1:myx,:) + model.gx(1:myx,:)*x_cu + model.Gxx(1:myx,:)*kron3(x_cu,x_cu);
        elseif model.appOrder == 3
            AA_cu = kron3(x_cu,x_cu);
            y1_cu = model.g0(1:myx,:) + model.gx(1:myx,:)*x_cu + model.Gxx(1:myx,:)*AA_cu ...
                + model.Gxxx(1:myx,:)*kron3(AA_cu,x_cu);
        end
        x_cup(model.mx+1:model.mx+myx) = y1_cu-model.gSS(1:myx);
    end
    x_cup(model.nx1+1:model.nx,1) = model.h0(model.nx1+1:model.nx,:) + model.hx(model.nx1+1:model.nx,:)*x_cu;
end

end